<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/XGame_template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>XGame</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->

<!-- InstanceEndEditable -->
<link type="text/css" rel="stylesheet" href="CSS/css.css" />
</head>

<body>
<?php
  include('lock.php');
?>
<div id="container">

<div id="wrapper">

<div id="banner">
<!-- InstanceBeginEditable name="TopLink" -->
<?php

$q = "SELECT user_name FROM user where user_ID = '$login_session'";
$result=mysql_query($q);
$data_fetch=mysql_fetch_array($result);
?>
<ul class="topLink">
<li> Welcome, <a href="UserProfile.php"> <?php echo $data_fetch['user_name']; ?> </a> </li>
<li> <a href="Wishlist.php"> Wishlist </a> &nbsp; | &nbsp;<a href="userShoppingCart.php"> Cart </a> </li>
<li> <a href="Logout.php"> Logout </a> </li>
</ul>
<!-- InstanceEndEditable -->

<img src="Assets/XGame.png" alt="XGame" />
</div>

<div id="menu">
<ul class="nav">
<form method="post" action="search_result.php">
<li> <span> <input type="text" placeholder="Search Keyword" name="search" />
&nbsp; <input type="submit" name="Search" value="Search" /> </span>
</li>
</form>
<li> <a href="Home.php"> Home </a> </li>
<li> <a href="ListOfNews.php"> News </a> </li>
<li> <a href="Games.php"> Games </a> </li>
<li> <a href="FAQ.php"> FAQ </a> </li>
<li> <a href="ContactUs.php"> Contact Us </a> </li>
</ul>

</div>

<div id="main">
<!-- InstanceBeginEditable name="Main" -->
<div class="verticalNav">
<h3> User Account </h3>
<ul>
<li> <a href="Wishlist.php"> Your Wishlist </a> </li>
<li> <a href="userShoppingCart.php"> Shopping Cart </a> </li>
<li> <a href="userCheckOutList.php"> Checkout List </a> </li>
<li> <a href="History.php"> History </a> </li>
</ul>
</div>

<div id="iframe">
<table border="0" class="table" >
<tr align="center">
<th class="tableHeader"> Product ID</th>
<th class="tableHeader"> Product Name </th>
<th class="tableHeader"> Quantity </th>
<th class="tableHeader">&nbsp;  </th>
<th class="tableHeader"> Unit Price </th>
<th class="tableHeader">&nbsp;  </th>
<th class="tableHeader"> Sub-Total Price </th>
<th class="tableHeader" colspan="3"> &nbsp; </th>
</tr>

<?php

  global $total;
  $q=mysql_query("SELECT demo_ID, COUNT(demo_ID) FROM cart WHERE user_ID='$login_session' GROUP BY demo_ID");
  while($data=mysql_fetch_array($q))
  {
      $num_demo_id=$data['COUNT(demo_ID)'];
      $demo_id=$data['demo_ID'];
      $ql=mysql_query("SELECT * FROM demo WHERE demo_ID='$demo_id'");
      $data_fetch=mysql_fetch_array($ql);
      
        $demo_price=number_format($data_fetch['demo_price'],2);
        $demo_name=$data_fetch['demo_name'];
        $sub =$demo_price *  $num_demo_id;
        $numform_sub=number_format($sub, 2);
        
        echo "<tr align='center'>";
        echo "<td class='tableContent'> $demo_id </td>";
        echo "<td class='tableContent'> &nbsp; $demo_name </td>";
        echo "<td class='tableContent'>  $num_demo_id </td>";
        echo "<td class='tableContent'> x </td>";
        echo "<td class='tableContent'> $ $demo_price </td>";
        echo "<td class='tableContent'> = </td>";
        echo "<td class='tableContent'> $ $numform_sub</td>";
        echo "<td class='tableContent'><form name='add' action='add.php' method='post'>
                                        <input type='hidden' name='addID' value='$demo_id' />
                                        <input type='submit' onClick='window.location.href=window.location.href' name='add' value='Add'/>
                                      </form>
                                    </td>";
        echo "<td class='tableContent'><form name='remove' action='remove.php' method='post'>
                                        <input type='hidden' name='removeID' value='$demo_id' />
                                        <input type='submit' onClick='window.location.href=window.location.href' value='Remove'/>
                                      </form>
                                    </td>";
        echo "<td class='tableContent'><form name='delete' action='delete.php' method='post'>
                                        <input type='hidden' name='deleteID' value='$demo_id' />
                                        <input type='submit' onClick='window.location.href=window.location.href' value='Delete'/>
                                      </form> 
                                    </td>";
        echo "</tr>";
      
     $total+=$numform_sub;
     $total=number_format($total, 2);
  }  
  
  if($total!=0)
  {
    echo "<tr>";
    echo "<td colspan='6' align='right' style='padding:3; background-color:#CCC'> <strong> Total Price &nbsp; </strong> </td>";
    echo "<td align='center' style='padding:3; background-color:#CCC'> $ $total </td>";
    echo "</tr>";
    echo "</table>";
    echo "<br />";

?>
    <form action="userConfirmation.php" method="post">
      <select name="location">
      <?php
        $sql="SELECT * FROM location";
        $result=mysql_query($sql);
        while($data_fetchlocation=mysql_fetch_array($result))
        {
          echo "<option value=".$data_fetchlocation['location_ID'].">".$data_fetchlocation['location_name']."</option>";        
        }
      ?>
      </select>

    &nbsp; &nbsp;

      <input type="hidden" name="total" value="<? echo $total ?>" />
      <input type="submit" onClick="window.location.href=window.location.href" name="checkout "value="Check Out"/>  
    </form>
    <?php
 }
?>
</table>
</div>
<!-- InstanceEndEditable -->
</div>

<div id="footer">
<p align="center"> &copy; &nbsp; 2012 XGame </p>
</div>

</div>

</div>

</body>
<!-- InstanceEnd --></html>
